<?php
/**
 * 前台栏目控制器
 */
class SearchAction extends CommonAction {

	protected $currentModel=null;
	protected $cacheData=array();

	public function _initialize()
	{
		parent::_initialize();
		$this->currentModel = D('Article');
	}	
	
	public function index()
	{
		import ('@.ORG.Page');
		$keyword=$this->_get('w');
		if(isset($keyword)&&$keyword!='')
		{			
	    	$map['title']=array('like','%'.$keyword.'%');
    		$map['stauts']=1;
			$count=$this->currentModel->where($map)->count();
    		$page = new Page($count,C ('PAGE_LIMIT'));
    		$datas=$this->currentModel->where($map)->relation('Comment')->limit($page->firstRow.','.$page->listRows)->order('id DESC')->select();
    		$this->assign('page',$page->show());
    		$this->assign('datas',$datas);    		    					
		}
	  	$seoInfo['seo_title']='关键词：'.$keyword;
	  	$seoInfo['seo_description']='关键词：'.$keyword;
	  	$seoInfo['seo_keywords']=$keyword;
    	$seo=seo($seoInfo);
    	$this->assign('seo',$seo);	  			
    	$this->assign('keyword',$keyword);   		
		$this->display();
	} 
}